using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication2.Models.Mapping
{
    public class FACodeMap : EntityTypeConfiguration<FACode>
    {
        public FACodeMap()
        {
            // Primary Key
            this.HasKey(t => new { t.Code, t.DescCode, t.IsHeader });

            // Properties
            this.Property(t => t.Code)
                .IsRequired()
                .HasMaxLength(20);

            this.Property(t => t.DescCode)
                .IsRequired()
                .HasMaxLength(100);

            // Table & Column Mappings
            this.ToTable("FACode");
            this.Property(t => t.Code).HasColumnName("Code");
            this.Property(t => t.DescCode).HasColumnName("DescCode");
            this.Property(t => t.IsHeader).HasColumnName("IsHeader");
        }
    }
}
